Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of different iovec struct layouts / enums #1086

Merged
merged 16 commits into from
Aug 13, 2024
Merged

Conversation

rafaelroquetto
Copy link
Contributor

@rafaelroquetto rafaelroquetto commented Aug 8, 2024

The Linux kernel has changed the layout of the iov_iter struct a few times since v5.8 (the minimum version we support). In particular:

  • until v5.13, the iterator type was represented by an unsigned int bitmask struct member called type. The bitmasks were defined by the iter_type enum. (reference)
  • from v5.14, the type bitmask was replaced with an 8-bit member called iter_type. This is no longer a bitmask, instead it carries a simple enumerator value. The iter_type enum was changed so that it is no longer defining bitmasks. (reference)
  • kernel v6.0 introduced a new iterator type in iter_type called ITER_UBUF - it was the last enumerator in the enum definition and was assigned the value of 6. (reference)
  • kernel v6.5 removed ITER_PIPE and reassigned ITER_BUF to 5 (reference)
  • kernel v6.7 reordered the iter_type enum, assigning ITER_UBUF a value of 0, and ITER_IOVEC a value of 1 (previously it was 0). (reference)

Beyla wasn't correctly checking for the type vs iter_type distinction, which caused the the iterator type to be wrongly resolved to 0 in kernel versions < 5.14. It was also assuming that the value of ITER_UBUF to be 6, which was no longer true for kernels above 6.10. These caused Beyla to wrongly parsing the incoming msg header buffer, thus failing to extract races.

The version of the cilium/ebpf component has been upgraded to v0.16.0 in order to address cilium/ebpf#1348 (git commit)

This issue is potentially related to #1055


Tested on the following kernel versions/distros

  • 5.10 - debian
  • 5.14 - opensuse
  • 6.1 - alpine
  • 6.4 - opensuse - note: OpenSuse 15.6 has a custom patched kernel (6.4.0-150600.23.7) with backported changes from v6.5 which removes ITER_PIPE
  • 6.6 - alpine
  • 6.10 - arch

@rafaelroquetto rafaelroquetto self-assigned this Aug 8, 2024
@rafaelroquetto rafaelroquetto added do-not-merge WIP or something that musn't be merged wip labels Aug 8, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.52%. Comparing base (29c0403) to head (e8bd75d).

❗ There is a different number of reports uploaded between BASE (29c0403) and HEAD (e8bd75d). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (29c0403) HEAD (e8bd75d)
unittests 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1086       +/-   ##
===========================================
- Coverage   81.93%   65.52%   -16.41%     
===========================================
  Files         140      171       +31     
  Lines       11427    13057     +1630     
===========================================
- Hits         9363     8556      -807     
- Misses       1544     3823     +2279     
- Partials      520      678      +158     
Flag Coverage Δ
integration-test 50.99% <ø> (-6.00%) ⬇️
k8s-integration-test 52.93% <ø> (-6.25%) ⬇️
oats-test 33.45% <ø> (-3.51%) ⬇️
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rafaelroquetto rafaelroquetto changed the title WIP: Fix handling of different iovec struct layouts / enums Fix handling of different iovec struct layouts / enums Aug 13, 2024
@rafaelroquetto rafaelroquetto marked this pull request as ready for review August 13, 2024 23:14
@rafaelroquetto rafaelroquetto removed do-not-merge WIP or something that musn't be merged wip labels Aug 13, 2024
Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@grcevski
Copy link
Contributor

Thanks for fixing this @rafaelroquetto!

@rafaelroquetto rafaelroquetto merged commit 6d04a14 into main Aug 13, 2024
6 checks passed
@rafaelroquetto rafaelroquetto deleted the iovec_fix branch August 13, 2024 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants